package com.bnz.shop.controller;

import com.bnz.shop.entity.TypeTemplateEntity;
import com.bnz.shop.service.TypeTemplateService;
import com.bnz.utils.PageUtils;
import com.bnz.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



@RestController
@RequestMapping("typetemplate")
public class TypeTemplateController {
	@Autowired
	private TypeTemplateService typeTemplateService;

	/**
	 * 列表
	 */
	@GetMapping("/list")
	public R list(@RequestParam Map<String, Object> params) {
		PageUtils page = typeTemplateService.queryPage(params);

		return R.ok().put("page", page);
	}

	/**
	 * 信息
	 */
	@GetMapping("/info/{id}")
	public R info(@PathVariable("id") String id) {
		TypeTemplateEntity typeTemplate = typeTemplateService.getById(id);

		return R.ok().put("typeTemplate", typeTemplate);
	}

	/**
	 * 保存
	 */
	@PostMapping("/save")
	public R save(@RequestBody TypeTemplateEntity typeTemplate) {
		typeTemplateService.save(typeTemplate);
		return R.ok();
	}

	/**
	 * 修改
	 */
	@PutMapping("/update")
	public R update(@RequestBody TypeTemplateEntity typeTemplate) {
		typeTemplateService.updateById(typeTemplate);
		return R.ok();
	}

	/**
	 * 删除
	 */
	@DeleteMapping("/delete")
	public R delete(@RequestBody String[] ids) {
		typeTemplateService.removeByIds(Arrays.asList(ids));

		return R.ok();
	}


}
